<template>
  <el-popover
    :placement="placement"
    :width="width"
    :trigger="trigger"
  >
    <ul class="popover-list">
      <li v-for="(item, index) in showList" :key="index">{{ item }}</li>
    </ul>
    <span class="popover-content" slot="reference">{{ showContent }}</span>
  </el-popover>
</template>
<script>
export default {
  props: {
    placement: {
      type: String,
      default: 'bottom-end'
    },
    width: {
      type: String,
      default: '300'
    },
    trigger: {
      type: String,
      default: 'hover'
    },
    popoverList: {
      type: Array,
      default: () => []
    },
    content: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      showContent: '',
      showList: []
    }
  },
  watch: {
    content (val) {
      this.showContent = val
    },
    popoverList (list) {
      this.showList = list
    }
  },
  methods: {
    clearData () {
      this.showContent = ''
      this.showList = []
    }
  }
}
</script>
<style lang="less" scoped>
.popover-content {
  width: 100%;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.popover-list {
  height: 200px;
  overflow: hidden;
  overflow-y: auto;
  li {
    padding: 5px 0;
    border-bottom: 1px dashed #ccc;
  }
}
</style>
